{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ec637c6c",
   "metadata": {},
   "source": [
    "# YOLO v2训练kmodel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "48ce86b6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "938647fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "# 基准测试通过\n",
    "# 来源：https://github.com/sipeed/maix_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e5d90503",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os, sys\n",
    "import shutil\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "403f39ef-9220-4aee-ad6a-341ea376d9b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "from train.detector_v1 import detector_train\n",
    "from train.detector.instance import config\n",
    "\n",
    "config.detector_train_epochs = 1 # 修改训练轮数 40"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5925150-db06-4c6f-9127-e8b46124a211",
   "metadata": {},
   "source": [
    "## config setting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b092b160",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-09-26_18_03\n"
     ]
    }
   ],
   "source": [
    "cur_time = time.strftime(\"%Y-%m-%d_%H_%M\", time.localtime())\n",
    "print(cur_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4e6ba73d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "../ubuntu/out/yolo_2021-09-26_18_03/\n"
     ]
    }
   ],
   "source": [
    "root_dir = os.path.abspath('..')\n",
    "ubuntu_path = f\"out/yolo_{cur_time}\" #用来mac中生成kmodel\n",
    "temp_saves_dir = f\"{root_dir}/ubuntu/{ubuntu_path}/\" #保存文件目录\n",
    "datasets_dir =  \"../datasets/ts_xml_format\" #upload_zip #数据源\n",
    "\n",
    "print(\"root_dir:\",root_dir)\n",
    "print(\"temp_saves_dir:\",temp_saves_dir)\n",
    "print(\"datasets_dir:\",datasets_dir)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1bd55a4c",
   "metadata": {},
   "source": [
    "## 训练函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ce47dd91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<os._wrap_close object at 0x7fd3d8b749d0>\n"
     ]
    }
   ],
   "source": [
    "## 清理隐藏文件\n",
    "#rm -f /Users/liampro/Downloads/pro/git/ai-test/k210/datasets/ts_xml_format/.DS_Store\n",
    "# rm -f /Users/liampro/Downloads/pro/git/ai-test/k210/datasets/ts_xml_format/*/.DS_Store\n",
    "cmd1 = f\"rm -f {datasets_dir}/.DS_Store\"\n",
    "cmd = f\"rm -f {datasets_dir}/*/.DS_Store\"\n",
    "os.popen(cmd1)\n",
    "f = os.popen(cmd)\n",
    "print(f)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a32b2b4",
   "metadata": {},
   "source": [
    "## 训练"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f485ba74",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "select gpu fail:NVML Shared Library Not Found\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-09-26 18:03:34,374 - [INFO]:  no GPU, will use [CPU]\n",
      "2021-09-26 18:03:37,251 - [INFO]:  input_shape: (224, 224, 3)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-- 0\n",
      "-- 1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-09-26 18:03:37,849 - [INFO]:  load datasets complete, check pass, images num:600, bboxes num:600\n",
      "2021-09-26 18:03:43,109 - [INFO]:  train, labels:['0', '1']\n",
      "2021-09-26 18:03:43,110 - [DEBUG]:  train, datasets dir:../datasets/ts_xml_format\n",
      "2021-09-26 18:03:43,111 - [INFO]:  bboxes num: 600, first bbox: [0.61160714 0.66071429]\n",
      "2021-09-26 18:03:43,338 - [INFO]:  bbox accuracy(IOU): 85.49%\n",
      "2021-09-26 18:03:43,338 - [INFO]:  bound boxes: (55.500000,60.50),(83.000000,81.00),(110.000000,111.00),(168.000000,169.00),(140.000000,137.00)\n",
      "2021-09-26 18:03:43,339 - [INFO]:  anchors: [1.734375, 1.890625, 2.59375, 2.53125, 3.4375, 3.46875, 5.25, 5.28125, 4.375, 4.28125]\n",
      "2021-09-26 18:03:43,340 - [INFO]:  w/h ratios: [0.92, 0.99, 0.99, 1.02, 1.02]\n",
      "2021-09-26 18:03:43.364606: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA\n",
      "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "self.anchors: [1.734375, 1.890625, 2.59375, 2.53125, 3.4375, 3.46875, 5.25, 5.28125, 4.375, 4.28125]\n",
      "load local weight file: /Users/liampro/Downloads/pro/git/ai-test/k210/k210_train/train/detector/weights/mobilenet_7_5_224_tf_no_top.h5\n",
      "Model: \"model\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "input_1 (InputLayer)         [(None, 224, 224, 3)]     0         \n",
      "_________________________________________________________________\n",
      "mobilenet_0.75_224 (Function (None, 7, 7, 768)         1832976   \n",
      "=================================================================\n",
      "Total params: 1,832,976\n",
      "Trainable params: 1,816,560\n",
      "Non-trainable params: 16,416\n",
      "_________________________________________________________________\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/envs/k210v37/lib/python3.7/site-packages/keras/optimizer_v2/optimizer_v2.py:356: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.\n",
      "  \"The `lr` argument is deprecated, use `learning_rate` instead.\")\n",
      "/opt/anaconda3/envs/k210v37/lib/python3.7/site-packages/keras/engine/training.py:1972: UserWarning: `Model.fit_generator` is deprecated and will be removed in a future version. Please use `Model.fit`, which supports generators.\n",
      "  warnings.warn('`Model.fit_generator` is deprecated and '\n",
      "2021-09-26 18:03:44,000 - [INFO]:  train start\n",
      "2021-09-26 18:03:44,000 - [INFO]:  progress: 1.0%, train start\n",
      "2021-09-26 18:03:44.009210: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2)\n",
      "2021-09-26 18:03:44,033 - [INFO]:  epoch 0 start\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"model_1\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "input_1 (InputLayer)         [(None, 224, 224, 3)]     0         \n",
      "_________________________________________________________________\n",
      "mobilenet_0.75_224 (Function (None, 7, 7, 768)         1832976   \n",
      "_________________________________________________________________\n",
      "detection_layer_35 (Conv2D)  (None, 7, 7, 35)          26915     \n",
      "_________________________________________________________________\n",
      "reshape (Reshape)            (None, 7, 7, 5, 7)        0         \n",
      "=================================================================\n",
      "Total params: 1,859,891\n",
      "Trainable params: 1,843,475\n",
      "Non-trainable params: 16,416\n",
      "_________________________________________________________________\n",
      "480/480 [==============================] - 107s 217ms/step - loss: 0.3390 - val_loss: 0.2247\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-09-26 18:05:31,485 - [INFO]:  epoch 0 end: {'loss': 0.3389566242694855, 'val_loss': 0.22467850148677826, 'lr': 1e-04}\n",
      "2021-09-26 18:05:31,486 - [INFO]:  progress: 98.0%, train epoch end\n",
      "2021-09-26 18:05:31,596 - [INFO]:  train end\n",
      "2021-09-26 18:05:31,597 - [INFO]:  progress: 98.0%, train end\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 00001: val_loss improved from inf to 0.22468, saving model to ../ubuntu/out/yolo_2021-09-26_18_03/m_best.h5\n",
      "save .h5 weights file to : ../ubuntu/out/yolo_2021-09-26_18_03/m_best.h5\n",
      "1-mins to train\n",
      "save .h5 weights file to : ../ubuntu/out/yolo_2021-09-26_18_03/m.h5\n",
      "save tfilte to : ../ubuntu/out/yolo_2021-09-26_18_03/m.tflite\n",
      "WARNING:tensorflow:From /opt/anaconda3/envs/k210v37/lib/python3.7/site-packages/keras/layers/normalization/batch_normalization.py:520: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Colocations handled automatically by placer.\n",
      "WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n",
      "WARNING:tensorflow:From /opt/anaconda3/envs/k210v37/lib/python3.7/site-packages/tensorflow/lite/python/util.py:300: convert_variables_to_constants (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use `tf.compat.v1.graph_util.convert_variables_to_constants`\n",
      "WARNING:tensorflow:From /opt/anaconda3/envs/k210v37/lib/python3.7/site-packages/tensorflow/python/framework/convert_to_constants.py:927: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use `tf.compat.v1.graph_util.extract_sub_graph`\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-09-26 18:05:35.543833: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)\n",
      "2021-09-26 18:05:35.543940: I tensorflow/core/grappler/clusters/single_machine.cc:357] Starting new session\n",
      "2021-09-26 18:05:35.848122: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:1137] Optimization results for grappler item: graph_to_optimize\n",
      "  function_optimizer: Graph size after: 3112 nodes (0), 3979 edges (0), time = 62.809ms.\n",
      "  function_optimizer: Graph size after: 3112 nodes (0), 3979 edges (0), time = 66.767ms.\n",
      "Optimization results for grappler item: conv_dw_1_bn_cond_true_10226\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.005ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_4_bn_cond_true_11055\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_1_bn_cond_false_10227\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_6_bn_cond_false_11530\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_12_bn_cond_true_12947\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_9_bn_cond_false_14848\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_3_bn_cond_true_10817\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_6_bn_cond_true_11529\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_13_bn_cond_true_15676\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_10_bn_cond_false_15123\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_9_bn_cond_true_12237\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv1_bn_cond_false_13277\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_12_bn_cond_true_15492\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_9_bn_cond_false_12238\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_2_bn_cond_true_10464\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_6_bn_cond_false_14296\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_7_bn_cond_false_14480\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_3_bn_cond_false_10701\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_12_bn_cond_true_12830\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_13_bn_cond_true_13066\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_10_bn_cond_false_15032\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_7_bn_cond_false_11766\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_5_bn_cond_true_14200\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_3_bn_cond_true_13830\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_10_bn_cond_false_12474\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_7_bn_cond_false_14571\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_3_bn_cond_false_10818\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_10_bn_cond_false_12357\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_10_bn_cond_true_12356\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_11_bn_cond_false_15216\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_11_bn_cond_true_15215\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_11_bn_cond_true_15306\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_13_bn_cond_false_15677\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_6_bn_cond_false_14387\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_13_bn_cond_false_13067\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_10_bn_cond_true_12473\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_4_bn_cond_true_13925\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_4_bn_cond_false_14017\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_2_bn_cond_false_13556\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_7_bn_cond_true_11765\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_13_bn_cond_true_13183\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_2_bn_cond_true_13555\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_3_bn_cond_false_13831\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_9_bn_cond_true_14938\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_4_bn_cond_false_10939\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_3_bn_cond_true_10700\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_1_bn_cond_true_10343\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_8_bn_cond_false_12002\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_5_bn_cond_true_11291\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_2_bn_cond_true_10581\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv1_bn_cond_true_13276\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_12_bn_cond_false_15493\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_9_bn_cond_false_14939\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_5_bn_cond_false_14110\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_6_bn_cond_false_11413\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_10_bn_cond_true_15122\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_6_bn_cond_true_11412\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_13_bn_cond_false_13184\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_11_bn_cond_true_12709\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_2_bn_cond_false_10582\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_8_bn_cond_true_14754\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_8_bn_cond_true_12001\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_3_bn_cond_true_13739\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_9_bn_cond_true_12120\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_13_bn_cond_false_15586\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_12_bn_cond_false_15402\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_1_bn_cond_true_13460\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_1_bn_cond_true_13369\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_8_bn_cond_true_14663\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_5_bn_cond_true_11174\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_7_bn_cond_false_11649\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_1_bn_cond_false_13461\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_5_bn_cond_false_14201\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_7_bn_cond_true_14479\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_11_bn_cond_true_12592\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_11_bn_cond_false_12710\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_1_bn_cond_false_13370\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_9_bn_cond_false_12121\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_10_bn_cond_true_15031\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_3_bn_cond_false_13740\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_8_bn_cond_false_14755\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_2_bn_cond_false_13647\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_4_bn_cond_true_14016\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_5_bn_cond_false_11292\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_6_bn_cond_true_14295\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_12_bn_cond_false_12948\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_6_bn_cond_true_14386\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_12_bn_cond_true_15401\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_11_bn_cond_false_15307\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_11_bn_cond_false_12593\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_7_bn_cond_true_11648\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_5_bn_cond_true_14109\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_2_bn_cond_true_13646\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_12_bn_cond_false_12831\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_8_bn_cond_false_14664\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv1_bn_cond_false_10108\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_4_bn_cond_true_10938\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_2_bn_cond_false_10465\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_1_bn_cond_false_10344\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_9_bn_cond_true_14847\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_8_bn_cond_true_11884\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_13_bn_cond_true_15585\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_4_bn_cond_false_13926\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_5_bn_cond_false_11175\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_8_bn_cond_false_11885\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv1_bn_cond_true_10107\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_7_bn_cond_true_14570\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_4_bn_cond_false_11056\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "\n",
      "2021-09-26 18:05:43.371774: W tensorflow/python/util/util.cc:348] Sets are not currently considered sequences, but this may change in the future, so consider avoiding using them.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Assets written to: /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp_j6pr13e/assets\n",
      "WARNING:tensorflow:From /opt/anaconda3/envs/k210v37/lib/python3.7/site-packages/tensorflow/lite/python/convert_saved_model.py:63: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorflow 2.0.\n",
      "INFO:tensorflow:Restoring parameters from /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp_j6pr13e/variables/variables\n",
      "INFO:tensorflow:The given SavedModel MetaGraphDef contains SignatureDefs with the following keys: {'serving_default', '__saved_model_init_op'}\n",
      "INFO:tensorflow:input tensors info: \n",
      "INFO:tensorflow:Tensor's key in saved_model's tensor_map: input_1\n",
      "INFO:tensorflow: tensor name: serving_default_input_1:0, shape: (-1, 224, 224, 3), type: DT_FLOAT\n",
      "INFO:tensorflow:output tensors info: \n",
      "INFO:tensorflow:Tensor's key in saved_model's tensor_map: reshape\n",
      "INFO:tensorflow: tensor name: StatefulPartitionedCall:0, shape: (-1, 7, 7, 5, 7), type: DT_FLOAT\n",
      "INFO:tensorflow:Restoring parameters from /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp_j6pr13e/variables/variables\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-09-26 18:05:53.294129: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)\n",
      "2021-09-26 18:05:53.294193: I tensorflow/core/grappler/clusters/single_machine.cc:357] Starting new session\n",
      "2021-09-26 18:05:53.611564: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:1137] Optimization results for grappler item: graph_to_optimize\n",
      "  function_optimizer: Graph size after: 1411 nodes (1130), 3074 edges (2522), time = 57.666ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 2.363ms.\n",
      "\n",
      "2021-09-26 18:05:55.094232: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)\n",
      "2021-09-26 18:05:55.094304: I tensorflow/core/grappler/clusters/single_machine.cc:357] Starting new session\n",
      "2021-09-26 18:05:55.129671: E tensorflow/core/grappler/grappler_item_builder.cc:669] Init node conv1/kernel/Assign doesn't exist in graph\n",
      "2021-09-26 18:05:55.432860: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:351] Ignored output_format.\n",
      "2021-09-26 18:05:55.432879: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:354] Ignored drop_control_dependency.\n",
      "2021-09-26 18:05:55.548469: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:210] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "anchors 2: [1.734375, 1.890625, 2.59375, 2.53125, 3.4375, 3.46875, 5.25, 5.28125, 4.375, 4.28125]\n",
      "save tfilte to : ../ubuntu/out/yolo_2021-09-26_18_03/m.tflite\n",
      "WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n",
      "2021-09-26 18:06:04.439222: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)\n",
      "2021-09-26 18:06:04.439306: I tensorflow/core/grappler/clusters/single_machine.cc:357] Starting new session\n",
      "2021-09-26 18:06:04.778434: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:1137] Optimization results for grappler item: graph_to_optimize\n",
      "  function_optimizer: Graph size after: 3112 nodes (0), 3979 edges (0), time = 64.224ms.\n",
      "  function_optimizer: Graph size after: 3112 nodes (0), 3979 edges (0), time = 69.182ms.\n",
      "Optimization results for grappler item: conv_dw_1_bn_cond_true_43061\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.004ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_11_bn_cond_true_45427\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_3_bn_cond_true_43535\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_3_bn_cond_false_43653\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_8_bn_cond_false_44720\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_11_bn_cond_true_48141\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_10_bn_cond_false_45309\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_11_bn_cond_false_48051\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_2_bn_cond_false_46482\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv1_bn_cond_true_46111\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_8_bn_cond_false_47590\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_2_bn_cond_true_43299\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_7_bn_cond_false_44601\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_4_bn_cond_true_46851\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_5_bn_cond_true_46944\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_1_bn_cond_true_46204\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_11_bn_cond_true_48050\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_1_bn_cond_false_46205\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_2_bn_cond_true_46390\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_5_bn_cond_false_47036\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_6_bn_cond_true_44364\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_12_bn_cond_true_45665\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_6_bn_cond_false_44248\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_10_bn_cond_true_47866\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_3_bn_cond_false_46666\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_9_bn_cond_false_44956\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_6_bn_cond_false_47222\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_13_bn_cond_true_45901\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_2_bn_cond_false_43417\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_6_bn_cond_true_47221\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_8_bn_cond_true_44836\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_5_bn_cond_true_44126\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_11_bn_cond_false_48142\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_10_bn_cond_true_47957\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_3_bn_cond_false_43536\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_12_bn_cond_false_48328\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv1_bn_cond_false_46112\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_13_bn_cond_false_48512\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_4_bn_cond_true_46760\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_8_bn_cond_true_47498\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_4_bn_cond_false_43891\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_6_bn_cond_true_47130\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_9_bn_cond_true_44955\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_6_bn_cond_false_44365\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_10_bn_cond_true_45191\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_9_bn_cond_true_47682\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_3_bn_cond_true_46574\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_7_bn_cond_false_44484\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_6_bn_cond_false_47131\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_8_bn_cond_false_44837\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_2_bn_cond_false_43300\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_12_bn_cond_false_45666\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_2_bn_cond_false_46391\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv1_bn_cond_false_42943\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_11_bn_cond_false_45545\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_10_bn_cond_false_45192\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_10_bn_cond_false_47958\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_11_bn_cond_false_45428\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_13_bn_cond_true_46018\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_9_bn_cond_true_45072\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_2_bn_cond_true_46481\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_12_bn_cond_true_45782\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_3_bn_cond_true_43652\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_7_bn_cond_true_44483\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_9_bn_cond_true_47773\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_4_bn_cond_true_43890\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_9_bn_cond_false_45073\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_4_bn_cond_false_46761\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_9_bn_cond_false_47683\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_13_bn_cond_false_48421\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_7_bn_cond_true_47314\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_10_bn_cond_true_45308\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_3_bn_cond_false_46575\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_7_bn_cond_false_47406\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_12_bn_cond_true_48236\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_12_bn_cond_true_48327\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_13_bn_cond_true_48420\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv1_bn_cond_true_42942\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_1_bn_cond_false_43062\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_5_bn_cond_true_44009\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_1_bn_cond_true_46295\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_7_bn_cond_false_47315\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_2_bn_cond_true_43416\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_13_bn_cond_false_45902\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_12_bn_cond_false_48237\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_5_bn_cond_false_44127\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_8_bn_cond_false_47499\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_1_bn_cond_false_46296\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_dw_6_bn_cond_true_44247\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_5_bn_cond_true_47035\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_1_bn_cond_true_43178\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_8_bn_cond_true_47589\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_5_bn_cond_false_44010\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_7_bn_cond_true_44600\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_11_bn_cond_true_45544\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_4_bn_cond_true_43773\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_10_bn_cond_false_47867\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_3_bn_cond_true_46665\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_12_bn_cond_false_45783\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.002ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_pw_13_bn_cond_false_46019\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_8_bn_cond_true_44719\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_13_bn_cond_true_48511\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_4_bn_cond_false_46852\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_9_bn_cond_false_47774\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: conv_dw_4_bn_cond_false_43774\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_dw_5_bn_cond_false_46945\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "Optimization results for grappler item: mobilenet_0.75_224_conv_pw_7_bn_cond_true_47405\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "Optimization results for grappler item: conv_pw_1_bn_cond_false_43179\n",
      "  function_optimizer: function_optimizer did nothing. time = 0.001ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 0ms.\n",
      "\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Assets written to: /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp8dh9ops6/assets\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Assets written to: /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp8dh9ops6/assets\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Restoring parameters from /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp8dh9ops6/variables/variables\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Restoring parameters from /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp8dh9ops6/variables/variables\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:The given SavedModel MetaGraphDef contains SignatureDefs with the following keys: {'serving_default', '__saved_model_init_op'}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:The given SavedModel MetaGraphDef contains SignatureDefs with the following keys: {'serving_default', '__saved_model_init_op'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:input tensors info: \n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:input tensors info: \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Tensor's key in saved_model's tensor_map: input_1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Tensor's key in saved_model's tensor_map: input_1\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow: tensor name: serving_default_input_1:0, shape: (-1, 224, 224, 3), type: DT_FLOAT\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow: tensor name: serving_default_input_1:0, shape: (-1, 224, 224, 3), type: DT_FLOAT\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:output tensors info: \n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:output tensors info: \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Tensor's key in saved_model's tensor_map: reshape\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Tensor's key in saved_model's tensor_map: reshape\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow: tensor name: StatefulPartitionedCall:0, shape: (-1, 7, 7, 5, 7), type: DT_FLOAT\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow: tensor name: StatefulPartitionedCall:0, shape: (-1, 7, 7, 5, 7), type: DT_FLOAT\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Restoring parameters from /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp8dh9ops6/variables/variables\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:tensorflow:Restoring parameters from /var/folders/_l/dffcyljj723fg4wbqfxfqv640000gn/T/tmp8dh9ops6/variables/variables\n",
      "2021-09-26 18:06:21.384128: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)\n",
      "2021-09-26 18:06:21.384186: I tensorflow/core/grappler/clusters/single_machine.cc:357] Starting new session\n",
      "2021-09-26 18:06:21.759280: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:1137] Optimization results for grappler item: graph_to_optimize\n",
      "  function_optimizer: Graph size after: 1411 nodes (1130), 3074 edges (2522), time = 73.885ms.\n",
      "  function_optimizer: function_optimizer did nothing. time = 3.02ms.\n",
      "\n",
      "2021-09-26 18:06:22.526514: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)\n",
      "2021-09-26 18:06:22.526595: I tensorflow/core/grappler/clusters/single_machine.cc:357] Starting new session\n",
      "2021-09-26 18:06:22.564406: E tensorflow/core/grappler/grappler_item_builder.cc:669] Init node conv1/kernel/Assign doesn't exist in graph\n",
      "2021-09-26 18:06:22.879190: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:351] Ignored output_format.\n",
      "2021-09-26 18:06:22.879205: W tensorflow/compiler/mlir/lite/python/tf_tfl_flatbuffer_helpers.cc:354] Ignored drop_control_dependency.\n",
      "2021-09-26 18:06:23,101 - [INFO]:  train ok, now generate report\n",
      "INFO:logger: train ok, now generate report\n",
      "2021-09-26 18:06:23,103 - [INFO]:  generate report image\n",
      "INFO:logger: generate report image\n",
      "2021-09-26 18:06:23,292 - [INFO]:  generate report image end\n",
      "INFO:logger: generate report image end\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<keras.callbacks.History object at 0x7fd3bb11f910>\n"
     ]
    }
   ],
   "source": [
    "# 配置文件：detector.instance\n",
    "result,_,model_path,anchors,labels = detector_train(datasets_dir=datasets_dir,temp_datasets_dir=temp_saves_dir,config=config)\n",
    "\n",
    "#result,_,model_path,anchors,labels = detector_train(datasets_zip_path=datasets_dir,temp_datasets_dir=temp_saves_dir,config=config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f7ab0e5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "../ubuntu/out/yolo_2021-09-26_18_03/m.h5\n",
      "[1.734375, 1.890625, 2.59375, 2.53125, 3.4375, 3.46875, 5.25, 5.28125, 4.375, 4.28125]\n"
     ]
    }
   ],
   "source": [
    "print(model_path)\n",
    "print(anchors)\n",
    "print(\"labels:\",labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "92068dd5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "ca541c61-03a4-4e8f-985f-131bf47c740f",
   "metadata": {
    "tags": []
   },
   "source": [
    "## 生成kmodel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "456feaa4-01ce-4374-ae4f-49d3856c7b07",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "docker run -it -v /Users/liampro/Downloads/pro/git/ai-test/k210/ubuntu:/train ubuntu /train/tokmodel.sh out/yolo_2021-09-26_18_03\n"
     ]
    }
   ],
   "source": [
    "#直接生成kmodel:Mac开发环境要弄个docker跑linux命令，\n",
    "# win,linux可以直接跑官方命令\n",
    "# tool:https://github.com/kendryte/nncase/releases/tag/v0.1.0-rc5\n",
    "\n",
    "exe_path = os.path.join(os.path.abspath('..'), \"ubuntu\")\n",
    "\n",
    "docker_cmd=f\"docker run -it -v {exe_path}:/train ubuntu /train/tokmodel.sh {ubuntu_path}\"\n",
    "print(docker_cmd)\n",
    "\n",
    "# 在shell 运行 docker命令"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0c7f1220",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "../ubuntu/ncc-linux-x86_64/ncc -i tflite -o k210model --dataset ../ubuntu/out/yolo_2021-09-26_18_03/sample_images ../ubuntu/out/yolo_2021-09-26_18_03/m.tflite ../ubuntu/out/yolo_2021-09-26_18_03/result/m.kmodel\n"
     ]
    }
   ],
   "source": [
    "# 或者运行下面的shell\n",
    "import os\n",
    "\n",
    "ncc_path = \"../ubuntu/ncc-linux-x86_64/ncc\" # \n",
    "cmd_linux = f\"{ncc_path} -i tflite -o k210model --dataset {temp_saves_dir}sample_images {temp_saves_dir}m.tflite {temp_saves_dir}result/m.kmodel\"\n",
    "print(cmd_linux)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e75a3379",
   "metadata": {},
   "outputs": [],
   "source": [
    "# f=os.popen(cmd_linux)\n",
    "# print(f.read())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "943e0391",
   "metadata": {},
   "source": [
    "## 生成k210程序boot.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e71f5080",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cp -f data/template/yolo_boot.py ../ubuntu/out/yolo_2021-09-26_18_03/result/boot.py\n"
     ]
    }
   ],
   "source": [
    "#temp_saves_dir = \"../ubuntu/out/yolo_1\"\n",
    "target_file = f\"{temp_saves_dir}result/boot.py\"\n",
    "copy_file = f\"cp -f data/template/yolo_boot.py {target_file}\"\n",
    "print(copy_file)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "def680cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "f=os.popen(copy_file)\n",
    "print(f.read()) \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "75f855f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 更新 labels ,anchors\n",
    "result_boot_py_path = target_file\n",
    "\n",
    "img_size = [224,224]\n",
    "#labels = [\"c0\",\"c1\"]\n",
    "replace = 'labels = [\"{}\"]'.format('\", \"'.join(labels))\n",
    "\n",
    "with open(result_boot_py_path) as f:\n",
    "            boot_py = f.read()\n",
    "with open(result_boot_py_path, \"w\") as f:\n",
    "            target = 'labels = [\"0\", \"1\"] # labels'\n",
    "            boot_py = boot_py.replace(target, replace)\n",
    "            target = 'anchors = [3.28125, 3.28125] # anchors'\n",
    "            replace = 'anchors = [{}]'.format(', '.join(str(i) for i in anchors))\n",
    "            boot_py = boot_py.replace(target, replace)\n",
    "            target = 'img_size = [224,224] # img_size'\n",
    "            replace = 'img_size = [{},{}]'.format(img_size[0], img_size[1])\n",
    "            boot_py = boot_py.replace(target, replace)\n",
    "            f.write(boot_py)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9de45392-8612-4ade-af61-d75a0045efc2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e6bc3c05-f166-4292-8797-ae7329fc4d4e",
   "metadata": {},
   "source": [
    "## 更新到k210 的cube硬件上运行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "fdbf9d42-9770-4737-a6b0-76f41c0ecee9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cmd: ls ../ubuntu/out/yolo_2021-09-26_18_03/result\n",
      "boot.py\n",
      "report.jpg\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 生成的文件\n",
    "cmd = f\"ls {temp_saves_dir}result\"\n",
    "print(\"cmd:\",cmd)\n",
    "f=os.popen(cmd)\n",
    "print(f.read())"
   ]
  },
  {
   "cell_type": "raw",
   "id": "df60a82c-63dc-40f5-a1ea-e53a429b3871",
   "metadata": {},
   "source": [
    "'''\n",
    "把 \n",
    "├── result\n",
    "│   ├── boot.py\n",
    "│   └── m.kmodel\n",
    "\n",
    "的 boot.py ，m.kmodel 复制到 sd 卡的根目录下（或者 models/m8/目录下）\n",
    "重新启动硬件，就可以运行了\n",
    "boot.py 代码中核实模型的路径是否正确\n",
    "\n",
    "'''"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
